<template>
  <div>
    <h1>Count</h1>

    <p>我的count的值是{{ count }}</p>
    <p>我的count的平方根的值是{{ countSqrt }}</p>
    <p>我的num的值是{{ num }}</p>
    <!-- <button @click="$store.commit('increament')">累加count的值</button>
    <button @click="$store.commit('increamentN',{n:3})">count的值加n</button> -->

    <button @click="increament">累加count的值</button>
    <button @click="increamentN({ n: 3 })">count的值加n</button>
    <button @click="incrementWait">过1s累加count的值</button>
    <button @click="incrementNWait({ n: 3 })">count的值过1s加n</button>
  </div>
</template>

<script>

export default {
  name: "Count",

  computed: {
    count() {
      return this.$store.state.count.count;
    },
    num() {
      return this.$store.state.count.num;
    },
    countSqrt() {
      return this.$store.getters["count/countSqrt"];
    },
  },
  methods: {
    increament() {
      this.$store.commit("count/increament");
    },
    increamentN(payload) {
      this.$store.commit("count/increamentN", payload);
    },
    incrementWait(){
      this.$store.dispatch("count/incrementWait")
    },
    incrementNWait(payload) {
      this.$store.dispatch("count/incrementNWait", payload);
    },
    
  },
};
</script>

<style scoped></style>
